<?php
$busca = addslashes($_POST["busca"]);
$db = new db(config::$driver);

$sql_protocolo = "select id from ci_protocolo where id like '%$busca%'";
$sql_assunto = "select id from ci_protocolo where assunto like '%$busca%'";
$sql_interessado = "select p.id from ci_protocolo p, ci_despachante d where (p.id_interessado = d.id or p.id_destinatario = d.id) and d.nome like '%$busca%'";
$sql_status = "select p.id from ci_protocolo p, ci_status s, ci_evento e where p.id = e.id_protocolo and e.id_status = s.id and s.descricao like '%$busca%'";

$i = 0;
$array = $db->select($sql_protocolo);
$cont_id_busca = 0;
while($array[$i]){
        $id_busca[$cont_id_busca] = $array[$i][0];
        $cont_id_busca++;
        $i++;
}
$i = 0;
$array = $db->select($sql_interessado);
while($array[$i]){
        $id_busca[$cont_id_busca] = $array[$i][0];
        $cont_id_busca++;
        $i++;
}

$i = 0;
$array = $db->select($sql_assunto);
while($array[$i]){
        $id_busca[$cont_id_busca] = $array[$i][0];
        $cont_id_busca++;
        $i++;
}
$i = 0;
$array = $db->select($sql_status);
while($array[$i]){
        $id_busca[$cont_id_busca] = $array[$i][0];
        $cont_id_busca++;
        $i++;
}
?>
